// 云函数入口文件
const cloud = require('wx-server-sdk')
//引入mysql操作模块
const mysql = require('mysql2/promise')
cloud.init()
 
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  try {
    const connection = await mysql.createConnection({
      host: "123.60.106.140",
      database: "bluealage",
      user: "bluealage",
      password: "8W4WEXD6cA223LaY"
    })
    const [rows, fields] = await connection.execute(event.sql)
    connection.end(function(err) {});
    return rows;
  } catch (err) {
    console.log("链接错误", err)
    return err
  }
}